{extend name="base" /}

{block name="main"}
<div class="box_form">

    <div class="box_content">
        <form class="layui-form" id="admin">
            <input type="hidden" name="token" value="{$token}" />
            <div class="layui-form-item">
                <label class="layui-form-label">上级导航</label>
                <div class="layui-input-inline">
                    <select name="pid">
                        <option value="0">作为顶级导航</option>
                        {volist name="$menus" id="vo"}
                        <option value="{$vo.id|raw}" {notempty name="$menu.pid|raw"}{eq name="$menu.pid|raw" value="$vo.id|raw"} selected=""{/eq}{else /}{notempty name="$pid"}{eq name="$pid" value="$vo.id|raw"} selected=""{/eq}{/notempty}{/notempty}>{$vo.str|raw}{$vo.name|raw}</option>
                        {/volist}
                    </select>
                </div>
            </div>
            {notempty name="$module"}
            <input type="hidden" name="module" value="{$module}">
            {/notempty}
            <div class="layui-form-item">
                <label class="layui-form-label">导航名称</label>
                <div class="layui-input-inline">
                    <input name="name" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input" type="text" {notempty name="$menu.name"}value="{$menu.name}"{/notempty}>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">导航别名</label>
                <div class="layui-input-inline">
                    <input name="alias" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input" type="text" {notempty name="$menu.alias"}value="{$menu.alias}"{/notempty}>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">链接地址</label>
                <div class="layui-input-inline">
                    <input name="value" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input" type="text" {notempty name="$menu.value"}value="{$menu.value}"{/notempty}>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">图标</label>
                <div class="layui-input-inline">
                    <input name="icon" placeholder="请输入" autocomplete="off" class="layui-input" type="text" {notempty name="$menu.icon"}value="{$menu.icon}"{/notempty}>
                </div>
                <div class="layui-form-mid layui-word-aux">例如：<i class="layui-icon" style="font-size: 30px; color: #1E9FFF;">&#xe68e;</i> <a class="layui-btn layui-btn-xs and-bg-{$skin_name|default='default'}" href="http://www.layui.com/doc/element/icon.html" target="_blank" >》找找</a></div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">状态</label>
                <div class="layui-input-inline">
                    <select name="status">
                        <option value="1" {notempty name="$menu.status"}{eq name="$menu.status" value="1"} selected=""{/eq}{/notempty}>显示</option>
                        <option value="2" {notempty name="$menu.status"}{eq name="$menu.status" value="0"} selected=""{/eq}{/notempty}>隐藏</option>
                    </select>
                </div>
            </div>


            <div class="layui-form-item">
                <label class="layui-form-label">排序</label>
                <div class="layui-input-inline">
                    <input name="orders" placeholder="请输入" lay-verify="required|number" autocomplete="off" class="layui-input" type="text" value="0" {notempty name="$menu.orders"}value="{$menu.orders}"{/notempty} >
                </div>
            </div>

            {notempty name="$menu"}
            <input type="hidden" name="id" value="{$menu.id}">
            {/notempty}
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn and-bg-{$skin_name|default='default'}" lay-submit lay-filter="admin">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>

        </form>
    </div>
</div>


{/block}


{block name="script"}
<script>
    layui.use(['layer', 'form'], function() {
        var layer = layui.layer,
                $ = layui.jquery,
                form = layui.form;
        $(window).on('load', function() {
            form.on('submit(admin)', function(data) {
                $.ajax({
                    url:"{:url('admin/nav/update')}",
                    data:$('#admin').serialize(),
                    type:'post',
                    async: false,
                    success:function(res) {
                        if(res.code == 1) {
                            layer.alert(res.msg, function(index){
                               location.href = res.url;
                                //parent.location.reload();
                            })
                        } else {
                            layer.msg(res.msg);
                        }
                    }
                });
                return false;
            });
        });
    });
</script>
{/block}